package com.kzj;

import com.kzj.common.config.ConfigProperties;
import com.kzj.fun.container.root.RootFrame;
import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;

import javax.swing.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {
    public static void main(String[] args) {
        if(args.length>1) {
            ConfigProperties.add(args[0]);
        }
        // 创建 Robot 对象

        // 获取 JNativeHook 的日志记录器
        Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());

        // 设置日志级别为 SEVERE，只显示严重错误
        logger.setLevel(Level.OFF);

        try {
            GlobalScreen.registerNativeHook();
        } catch (NativeHookException ex) {
            System.err.println("There was a problem registering the native hook.");
            System.err.println(ex.getMessage());
            System.exit(1);
        }

        SwingUtilities.invokeLater(() -> {
            RootFrame rootFrame = new RootFrame();
            GlobalScreen.addNativeKeyListener(rootFrame);
        });


    }
}